/**
 * 生成 guid
 * @returns 
 */
export function generateGuid () {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0,
            v = c === 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
    });
}

/**
 * 递归去除空的 children
 * @param {*} arr 
 * @returns 
 */
export function dataManage (arr, level = 0) {
    for (let i = 0; i < arr.length; i++) {
        const item = arr[i];
        if (level >= 2) {
            item.village = item.children
            // item.village.push({
            //     label: '无',
            //     value: '0'
            // })
            delete item.children;
        }
        if (item.children && item.children.length > 0) {
            dataManage(item.children, level + 1);
        } else if (item.children && item.children.length === 0) {
            delete item.children;
        }
    }
    return arr;
}

//用于返回文件的路径，获取本地和IIS。
export function getUrl () {
    var pathName = window.location.pathname.substring(1);
    var webName =
        pathName == ''
            ? ''
            : pathName.substring(0, pathName.indexOf('/'));
    // var url =
    //     window.location.protocol +
    //     '//' +
    //     window.location.host +
    //     '/' +
    //     webName;
    // if (webName == '' || webName == null) { //拼接路径
    //     url = url + '/';
    // } else {
    //     url = url + '/';
    // }
    return '/'+webName;
}